#!/bin/sh

myPath=$(cd `dirname $0`; pwd)

# 安装vim工具
yum -y install vim*
#yum install gcc --nogpgcheck
# 环境安装
yum install -y yum-utils

#1.卸载旧的版本
yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

# 阿里云地址
yum-config-manager \
    --add-repo \
    http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

#更新yum 索引
yum makecache fast

#安装docker 指定版本
yum install -y docker-ce-19.03.9 docker-ce-cli-19.03.9 containerd.io

# 新建docker目录
mkdir -p /etc/docker

# 添加阿里云加速
tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://vdjok7m9.mirror.aliyuncs.com"]
}
EOF

# 启动docker,并设置成开机启动
sudo systemctl daemon-reload
sudo systemctl enable docker
sudo systemctl start docker

docker version

curl -L https://get.daocloud.io/docker/compose/releases/download/1.27.4/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

cd /usr/local/bin/

sudo chmod +x docker-compose

docker-compose version

# 更新系统时间
#yum update -y
yum install ntpdate -y
# 虚拟机
#ntpdate time.windows.com
# 非虚拟机
ntpdate us.pool.ntp.org

# 构建springboot 应用镜像
docker build -t app $myPath
# 启动应用
#cd $myPath
#docker-compose up

#setfacl -R -d -m u:root:rwx /home/install-app/ftp
#setfacl -R -d -m g:root:rwx /home/install-app/ftp
#setfacl -R -d -m u:ftp:rwx /home/install-app/ftp
#setfacl -R -d -m g:ftp:rwx /home/install-app/ftp
#setfacl -R -d -m o::rwx /home/install-app/ftp